<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>书籍信息管理</title>
	<meta name="decorator" content="default"/>
    <script src="https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.js"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
        function selectRow(id) {
            $("#"+id).attr('checked', 'true');
            var outBookCatalogPName=$("#"+id).attr("outBookCatalogPName");
            var outBookCatalogName=$("#"+id).attr("outBookCatalogName");
            var outBookCode=$("#"+id).attr("outBookCode");
            var outBookId=$("#"+id).attr("outBookId");
            var outBookName=$("#"+id).attr("outBookName");
            localStorage.setItem("outBookCatalogPName",outBookCatalogPName);
            localStorage.setItem("outBookCatalogName",outBookCatalogName);
            localStorage.setItem("outBookCode",outBookCode);
            localStorage.setItem("outBookId",outBookId);
            localStorage.setItem("outBookName",outBookName);
        }
        function query(i) {
            var actionValue=$("searchForm").attr("action");
            var bookCodeValue=$("bookCode").val();
            var bookNameValue=$("bookName").val();
            if(i==0){
                actionValue=actionValue+"/bookCode="+bookCodeValue;
            }
            if(i==1){
                actionValue=actionValue+"/bookName="+bookNameValue;
            }

        }
	</script>
</head>
<body>
	<form:form id="searchForm" modelAttribute="baseBook" action="${ctx}/base/book/baseBook/selectBook" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>图书编号：</label>
				<form:input path="bookCode" htmlEscape="false" maxlength="20" class="input-medium"/>
			</li>
			<li><label>图书名称：</label>
				<form:input path="bookName" htmlEscape="false" maxlength="20" class="input-medium"/>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
                <th style="text-align:center;">选择</th>
				<th>图书编号</th>
				<th>图书名称</th>
				<th>单价</th>
				<th>总计</th>
				<th>信息</th>
				<th>备注</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="baseBook">
			<tr onclick="selectRow('${baseBook.id}')">
                <td style="text-align:center;">
                    <input type="radio" name="id" id="${baseBook.id}" value="${baseBook.id}"
                           outBookCatalogPName="${baseBook.bookCatalogP.name}"
                           outBookCatalogName="${baseBook.bookCatalog.name}"
                           outBookCode="${baseBook.bookCode}"
                           outBookId="${baseBook.id}"
                           outBookName="${baseBook.bookName}"
                    />
                </td>
				<td>
					${baseBook.bookCode}
				</a></td>
				<td>
					${baseBook.bookName}
				</td>
				<td>
					${baseBook.bookPrice}元
				</td>
				<td>
					${baseBook.bookNum}本
				</td>
				<td>
					${baseBook.bookInfo}
				</td>
				<td>
					${baseBook.remarks}
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>